<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CustomGradient</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">CustomGradient()</font></b></p>
<p><b>语法</b></p><blockquote>
<font color="#006666"><b>CustomGradient</b></font>(@GradientCallback())</blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Sets the drawing gradient to have a custom shape, defined by the given callback procedure. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>@GradientCallback()</i></td>
<td width="90%"> 
 
The address of a callback procedure to define the gradient. 
The callback must have the following form: 
 
<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Procedure</font></b>.f <font color="#006666">GradientCallback</font>(x, y)
    <font color="#006666">;</font>
    <font color="#006666">; Return a value between 0.0 and 1.0 to define the gradient for the x/y position.</font>
    <font color="#006666">; </font>
    <b><font color="#006666">ProcedureReturn</font></b> 1.0
  <b><font color="#006666">EndProcedure</font></b>
</font></pre>



The callback will be called for every pixel that is part of a drawing operation. The callback 
has to return a value between 0.0 and 1.0 (not a color value) to define the gradient value at the given position. 
<br>
<br>
The x and y coordinate received in the callback are always relative to the upper left corner of 
the drawing output. The coordinates are not affected by any calls to <a href="setorigin.html">SetOrigin()</a> or <a href="clipoutput.html">ClipOutput()</a>. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>
无.


</blockquote><p><b>Remarks</b></p><blockquote>



By default the value 0.0 represents the current <a href="backcolor.html">background color</a> and the value 1.0 represents 
the current <a href="frontcolor.html">front color</a>. 
Additional colors can be added to the gradient with the <a href="gradientcolor.html">GradientColor()</a> command. 
<br>
<br>
This callback will be called many times (for every pixel to draw) so it should be very small and 
fast to not have a too big impact on the drawing performance. 
<br>
<br>
Note: This command only has an effect with <a href="../image/imageoutput.html">ImageOutput()</a> and <a href="../gadget/canvasoutput.html">CanvasOutput()</a>. 
The gradient only affects the drawing commands when <font color="#924B72">#PB_2DDrawing_Gradient</font> is 
set with the <a href="drawingmode.html">DrawingMode()</a> command. 

 

</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Procedure</font></b>.f <font color="#006666">GradientCallback</font>(x, y)
    <b><font color="#006666">ProcedureReturn</font></b> <font color="#006666">Sin</font>(x * 0.1) *<font color="#006666"> Sin</font>(y * 0.1) <font color="#006666">; will be between 0 and 1</font>
  <b><font color="#006666">EndProcedure</font></b>

  <b><font color="#006666">If</font></b> <font color="#006666">OpenWindow</font>(0, 0, 0, 400, 200, "2DDrawing Example", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
    <b><font color="#006666">If</font></b> <font color="#006666">CreateImage</font>(0, 400, 200) <b><font color="#006666">And</font></b> <font color="#006666">StartDrawing</font>(<font color="#006666">ImageOutput</font>(0))
<font color="#006666">      Box</font>(0, 0, 400, 200, $FFFFFF)
      
<font color="#006666">      DrawingMode</font>(<font color="#924B72">#PB_2DDrawing_Gradient</font>)      
<font color="#006666">      BackColor</font>($00FFFF)
<font color="#006666">      FrontColor</font>($FF0000)
      
<font color="#006666">      CustomGradient</font>(@GradientCallback())
<font color="#006666">      Circle</font>(100, 100, 100)   
<font color="#006666">      Circle</font>(300, 100, 100)
      
<font color="#006666">      StopDrawing</font>() 
<font color="#006666">      ImageGadget</font>(0, 0, 0, 400, 200,<font color="#006666"> ImageID</font>(0))
    <b><font color="#006666">EndIf</font></b>
    
    <b><font color="#006666">Repeat</font></b>
      Event =<font color="#006666"> WaitWindowEvent</font>()
    <b><font color="#006666">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#006666">EndIf</font></b>
</font></pre>

<br>
<p><img src="../HelpPictures/customgradient.png"></p>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="gradientcolor.html">GradientColor()</a>, <a href="resetgradientcolors.html">ResetGradientColors()</a>, 
<a href="lineargradient.html">LinearGradient()</a>, <a href="circulargradient.html">CircularGradient()</a>, 
<a href="ellipticalgradient.html">EllipticalGradient()</a>, <a href="boxedgradient.html">BoxedGradient()</a>, <a href="conicalgradient.html">ConicalGradient()</a>, 
<a href="drawingmode.html">DrawingMode()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=customfiltercallback.html>CustomFilterCallback()</a> - <a href=index.html>2DDrawing Index</a> - <a href=drawalphaimage.html>DrawAlphaImage()</a> -&gt;



</body></html>